<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>乘积最大子数组</title>
</head>
<body>
  <script>
    function fn(nums) {
      let mx = nums[0], mn = nums[0], res = nums[0];
      for (const num of nums.slice(1)) {
          let mx_ = mx;
          mx = Math.max(num, num * mx, num * mn);
          mn = Math.min(num, num * mx_, num * mn);
          res = Math.max(res, mx);
      }
      return res;
    }
    console.log(fn())
  </script>
</body>
</html>